const express = require('express')
const router = express.Router()
const settingService = require('services/setting')
const BANNER_SETTING = 'Banners'

router.get('/', async (req, res) => {
  let banners = await settingService.get(BANNER_SETTING)
  if (banners) {
    banners = JSON.parse(banners)
  } else {
    banners = []
  }
  if (banners.constructor !== Array) {
    banners = []
  }
  res.json(banners)
})

module.exports = router